package com.guangyunl.k_exam;
// 笔记本类
public class NoteBook {
    // 开机
    public void start(){
        System.out.println("笔记本开机");
    }

    // 使用USB
    /*
    USB usb = mouse 多态
    USB usb = keyBoard 多态
     */
    public void useUSB(USB usb){
//        usb.open();
//        usb.close();
        if (usb instanceof Mouse){
            Mouse mouse = (Mouse) usb;
            mouse.open();
            mouse.click();
            mouse.close();
        }

        if (usb instanceof KeyBoard){
            KeyBoard keyBoard = (KeyBoard) usb;
            keyBoard.open();
            keyBoard.input();
            keyBoard.close();
        }

    }

    // 关机
    public void stop(){
        System.out.println("笔记本关机");
    }


}
